"""luffyapi URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path, include
from django.conf import settings
from django.views.static import serve

# 添加 xadmin 支持
import xadmin

xadmin.autodiscover()
# version模块自动注册需要版本控制的model
from xadmin.plugins import xversion

xversion.register_models()

# jwt
from rest_framework_jwt.views import obtain_jwt_token

urlpatterns = [
    path('admin/', admin.site.urls),
    path('xadmin/', xadmin.site.urls),  # 支持 xadmin 超级用户root pwd 123456
    #
    re_path(r'media/(?P<path>.*)', serve, {"document_root": settings.MEDIA_ROOT}),
    # 富文本编辑器
    path(r'ckeditor/', include('ckeditor_uploader.urls')),
    # apps下的子应用home应用
    path(r"", include("home.urls")),
    # apps下的子应用user
    path(r"user/", include("user.urls")),
    # jwt 的用户认证
    re_path(r'^api-token-auth/', obtain_jwt_token),
    # 课程分类
    path(r"course/", include("course.urls")),
    # 购物车
    path('cart/', include('cart.urls')),
    # 订单
    path('order/', include('order.urls')),
    # 优惠券
    path('coupon/', include('coupon.urls')),
    # 支付
    path('payment/', include('payment.urls')),
]
